<template>
  <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <!-- trim情况空字符 -->
      <input class="new-todo" placeholder="请输入任务名称" autofocus @keyup.enter="todoThings" v-model.trim="todoName" />
    </header>
</template>
 
<script>
export default {

  components: {},
  props: {},
  data() {
    return {
      todoName:'',
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    /* 添加事件 */
    todoThings(){
      /* 子传父， */
      if (!this.todoName) return alert('内容不能为空')
      this.$emit('todoThings',this.todoName)
      /* 传完以后清空内容 */
      this.todoName= ''
    }
    
  }
};
</script>

<style scoped>
     
</style>